<?php
header("Access-Control-Allow-origin:*");
$type = $_POST["typeval"];
$page = $_POST["page"] ? $_POST["page"] : 1;
$arr = [];
$resArr = [];
$num = 10;
$start = ($page - 1) * $num + 1;
$end = $page * 10;

if ($page == 6) {
    $end = $page * 10 - 5;
}

if ($type == "1" || !$type) {
    for ($i = $start; $i <= $end; $i++) {
        $arr[] = array(
            "id" => $i,
            "title" => "装修/设计" . $i,
            "img" => "/static/upload/01.jpg",
            "promotion" => "满20000减500"
        );
    }
} else if ($type == "2") {
    for ($i = $start; $i <= $end; $i++) {
           $arr[] = array(
            "id" => $i,
            "title" => "建材/软装" . $i,
            "img" => "/static/upload/01.jpg",
            "promotion" => "满20000减500"
        );
    }

} 

$resArr["ok"] = 1;
$resArr["data"] = $arr;

// $rand = mt_rand(0, 1);

// if ($rand) {

// } else {
//     $resArr["ok"] = 0;
//     $resArr["error"] = array(
//         'code' => $ph->getErrorCode(),
//         'message' => $ph->getErrorMessage(),
//     );
// }
echo json_encode($resArr);

?>